<?php

namespace App\Services\Account;

use App\Models\VipPurchase;
use Illuminate\Database\Eloquent\Relations\HasMany;

class AccountBalances extends AccountAbstract
{
    protected function account(): HasMany
    {
        return $this->user->accounts();
    }

    protected function account_field()
    {
        return 'balance';
    }


    public function minusOrderPaid($money, $data = [])
	{
		$money = big_decimal($money)->multipliedBy(-1);

		$this->record($money, 'pay_order', '积分支付商品订单', $data);
	}

	 public function minusBoxOrderPaid($money, $data = [])
	{
		$money = big_decimal($money)->multipliedBy(-1);

		$this->record($money, 'pay_box_order', '余额支付盲盒商品', $data);
	}
	
	public function minusVipPaid($money, $data = [])
	{
		$money = big_decimal($money)->multipliedBy(-1);
		$this->record($money, 'pay_vip_purchase', '余额支付会员账号', $data);

	}

	public function plusTakeBalance($money, $data = [])
	{
		$money = big_decimal($money);
		$this->record($money, 'transfered_in_balances', '红包领取转入余额', $data);

	}

	public function plusSystemTransferCoins($money, $data = [])
	{
        $money = big_decimal($money);
		$this->record($money, 'system_transfer_coins', '平台积分转账', $data);
	}

	public function minusSystemRecall($money, $data = [])
	{
		$money = big_decimal($money)->multipliedBy(-1);
		$this->record($money, 'system_recall', '系统回收', $data);
	}
}
